package huaweiod.third;

import java.util.*;

/**
 * 比赛的冠亚季军
 * https://blog.csdn.net/qfc_128220/article/details/130769633
 */
public class B_Competition {

    static class Sportsman {
        public int id;
        public int power;

        public Sportsman(int id, int power) {
            this.id = id;
            this.power = power;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
//        List<Sportsman> arr = new ArrayList<>();
        List<Sportsman> win = new ArrayList<>();
        List<Sportsman> loser = new ArrayList<>();
        int[] ints = Arrays.stream(in.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        for (int i = 0; i < ints.length; i = i + 2) {
            if (i + 1 == ints.length) {
                win.add(new Sportsman(i, ints[i]));
            } else {
                if (ints[i] >= ints[i + 1]) {
                    win.add(new Sportsman(i, ints[i]));
                    loser.add(new Sportsman(i + 1, ints[i + 1]));
                } else {
                    win.add(new Sportsman(i + 1, ints[i + 1]));
                    loser.add(new Sportsman(i, ints[i]));
                }
            }
        }
        Stack<List<Sportsman>> stack = new Stack<>();
        stack.add(loser);
        stack.add(win);
        StringJoiner sj = new StringJoiner(" ");
        int count = 0;
        while (count < 3 && !stack.isEmpty()) {
            List<Sportsman> pop = stack.pop();
            if (pop.size() == 1) {
                sj.add(String.valueOf(pop.get(0).id));
                count++;
            } else if (pop.size() == 2) {
                count++;
                if (pop.get(0).power >= pop.get(1).power) {
                    sj.add(String.valueOf(pop.get(0).id));
                    if (count < 3) {
                        sj.add(String.valueOf(pop.get(1).id));
                        count++;
                    }
                } else {
                    sj.add(String.valueOf(pop.get(1).id));
                    if (count < 3) {
                        sj.add(String.valueOf(pop.get(0).id));
                        count++;
                    }
                }
            } else {
                List<Sportsman> win1 = new ArrayList<>();
                List<Sportsman> loser1 = new ArrayList<>();
                for (int i = 0; i < pop.size(); i = i + 2) {
                    if (i + 1 == pop.size()) {
                        win1.add(new Sportsman(pop.get(i).id, pop.get(i).power));
                    } else {
                        if (pop.get(i).power >= pop.get(i + 1).power) {
                            win1.add(new Sportsman(pop.get(i).id, pop.get(i).power));
                            loser1.add(new Sportsman(pop.get(i + 1).id, pop.get(i + 1).power));
                        } else {
                            win1.add(new Sportsman(pop.get(i + 1).id, pop.get(i + 1).power));
                            loser1.add(new Sportsman(pop.get(i).id, pop.get(i).power));
                        }
                    }
                }
                stack.push(loser1);
                stack.push(win1);
            }
        }
        System.out.println(sj);
    }
}
